package com.evil.application.strategy.application;

import com.evil.application.pojo.dto.CopyApplicationDTO;
import com.evil.application.pojo.entity.ApplicationInfo;
import com.evil.application.service.ApplicationViewService;
import com.evil.common.application.enums.ApplicationTypeEnum;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Slf4j
@Service
@AllArgsConstructor
public class ViewApplicationOperation implements ApplicationOperation {

    private final ApplicationViewService applicationViewService;

    /**
     * 应用类型
     *
     * @return ApplicationTypeEnum
     */
    @Override
    public ApplicationTypeEnum type() {
        return ApplicationTypeEnum.VIEW_APP;
    }

    /**
     * 新增应用
     *
     * @param applicationInfo applicationInfo
     */
    @Override
    public void addApplication(ApplicationInfo applicationInfo) {

    }

    /**
     * 删除应用
     *
     * @param applicationInfo applicationInfo
     */
    @Override
    public void deleteApplication(ApplicationInfo applicationInfo) {
        applicationViewService.deleteByApp(applicationInfo);
    }

    /**
     * 复制应用
     *
     * @param copyApplicationDTO copyApplicationDTO
     */
    @Override
    public void copyApplication(CopyApplicationDTO copyApplicationDTO) {
        applicationViewService.copyByApp(copyApplicationDTO);
    }

    /**
     * 发布应用
     *
     * @param applicationInfo applicationInfo
     */
    @Override
    public void publishApplication(ApplicationInfo applicationInfo) {
        applicationViewService.publishView(applicationInfo);
    }

    /**
     * 还原应用
     *
     * @param applicationInfo applicationInfo
     */
    @Override
    public void restoreApplication(ApplicationInfo applicationInfo) {
        applicationViewService.restoreView(applicationInfo);
    }
}
